home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / haeberli / fonttools / textmap.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  2KB  |  102 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  *    textmap - 
  19.  *        Use texture mapping to draw text.
  20.  *
  21.  *                Paul Haeberli - 1991
  22.  *
  23.  */
  24. #include "stdio.h"
  25. #include "gl.h"
  26. #include "device.h"
  27. #include "textmap.h"
  28.  
  29. #define NREP        (1)
  30. #define WINSIZE        (700)
  31.  
  32. main(argc,argv)
  33. int argc;
  34. char **argv;
  35. {
  36.     texfnt *tfnt;
  37.     short val;
  38.     float t;
  39.     int i, rep;
  40.  
  41.     if( argc<2 ) {
  42.     fprintf(stderr,"usage: textmap font.bw\n");
  43.     exit(1);
  44.     } 
  45.     for(i=0; i<10; i++) {
  46.     tfnt = readtexfont(argv[1]);
  47.     if(!tfnt ) {
  48.         fprintf(stderr,"textmap: can't open input font\n");
  49.         exit(1);
  50.     } 
  51.     fprintf(stderr,".");
  52.  
  53.     } 
  54.     prefsize(WINSIZE,WINSIZE);
  55.     winopen("textmap");
  56.     subpixel(1);
  57.     RGBmode();
  58.     doublebuffer();
  59.     gconfig();
  60.  
  61.     qdevice(ESCKEY);
  62.  
  63.     cpack(0xffe0e0e0);
  64.     clear();
  65.     swapbuffers();
  66.  
  67.     blendfunction(BF_SA,BF_MSA);
  68.     texfont(tfnt);
  69.     translate(WINSIZE/2.0,WINSIZE/2.0,0.0);
  70.     scale(25.0,25.0,1.0);
  71.     while(1) {
  72.     cpack(0xffe0e0e0);
  73.     clear();
  74.     cpack(0xff000000);
  75.  
  76.     for(rep=0; rep<NREP; rep++) {
  77.         pushmatrix();
  78.         for(i=0; i<20; i++) {
  79.         pushmatrix();
  80.         texcharstr("    Hello there! How do you like this?");
  81.         popmatrix();
  82.         rot(18.0,'z');
  83.         scale(0.96,0.96,0.96);
  84.         }
  85.         popmatrix();
  86.     }
  87.  
  88.     swapbuffers();
  89.     rot(0.2,'z');
  90.     if(qtest()) {
  91.         switch(qread(&val)) {
  92.          case REDRAW:
  93.              reshapeviewport();
  94.              break;
  95.          case ESCKEY:
  96.              exit(0);
  97.              break;
  98.         }
  99.     }
  100.     }
  101. }
  102.